package MapDemo;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;

public class HashMapDemo1 {
    public static void main(String[] args) {
        HashMap<Teacher, String> map = new HashMap<Teacher,String>();
        //向集合中添加数据
        map.put(new Teacher("黑旋风",20), "黑龙江");
        map.put(new Teacher("助教",24), "上海");
        map.put(new Teacher("班导",28), "江苏");
        map.put(new Teacher("黑旋风",20), "上海");
        Set<Teacher> keys = map.keySet();
        //迭代集合
        for (Iterator<Teacher> it = keys.iterator(); it.hasNext();) {
            Teacher key =  it.next();
            //获得value
            String value = map.get(key);
            System.out.println(key+"----"+value);
        }
    }
}
